/*
 * @Author: xiaosihan 
 * @Date: 2022-08-20 17:08:13 
 * @Last Modified by: xiaosihan
 * @Last Modified time: 2024-10-20 13:57:12
 */
import hashHistory from '@hashHistory';
import loadable from "@loadable/component";
import LoginModal from '@views/pc/LoginModal/LoginModal';
import 'antd-mobile/es/global';
import zhCN from 'antd/locale/zh_CN';
import getBrowserInfo from "get-browser-info";
import ReactDOM from 'react-dom/client';
import { Route, unstable_HistoryRouter as Router, Routes } from 'react-router-dom';
import './index.css';

import ConfigProvider from 'antd/es/config-provider';// antd 主题配置
import PartsLibrary from '@views/pc/PartsLibrary/PartsLibrary';
import PartCollaborate from '@views/pc/PartCollaborate/PartCollaborate';
import Inquiry from '@views/pc/Inquiry/Inquiry';
import ProjectDatail from '@views/pc/ProjectDatail/ProjectDatail';
import ProjectSetting from '@views/pc/ProjectSetting/ProjectSetting';
import AccountSettings from '@views/pc/AccountSettings/AccountSettings';
import UserCenter from '@views/pc/UserCenter/UserCenter'; // 个人中心
import FQRS from '@views/pc/FQRS/FQRS'; // 报价页面
import UserOrder from '@views/pc/UserOrder/UserOrder'; // 用户订单
import PCHome from "@views/pc/home/Home";
import PartsDetails from "@views/pc/PartsDetails/PartsDetails"; // 查看零件详情
import UpdataModel from "@views/pc/UpdataModel/UpdataModel";  // pc 上传模型获取报价页面
import NotFind from '@views/pc/404/NotFind';
import FileLookModal from '@views/pc/component/FileLookModal/FileLookModal';
import PartCollaborateDemo from "@views/pc/PartCollaborateDemo/PartCollaborateDemo";
import ProjectCollaboration from '@views/pc/ProjectCollaboration/ProjectCollaboration'; // 项目管理
import FactoryCenter from '@views/factory/FactoryCenter/FactoryCenter';
import AdminUserManage from '@views/admin/AdminUserManage/AdminUserManage';
import AdminFactoryManage from '@views/admin/AdminFactoryManage/AdminFactoryManage';
import AdminServerType from '@views/admin/AdminServerType/AdminServerType';
import AdminProcessCategory from '@views/admin/AdminProcessCategory/AdminProcessCategory';
import { Affix, Button } from 'antd';


// 后台登录页面
const AdminLogin = loadable(() => import("./views/admin/AdminLogin/AdminLogin"));
const AdminLayer = loadable(() => import("@views/admin/AdminLayer/AdminLayer"));

//工厂端登录
const FactoryLayer = loadable(() => import("@views/factory/FactoryLayer/FactoryLayer"));
const FactorySetting = loadable(() => import("@views/factory/FactorySetting/FactorySetting"));
const FactoryOrder = loadable(() => import("@views/factory/FactoryOrder/FactoryOrder"));
const FactoryQuotation = loadable(() => import("@views/factory/FactoryQuotation/FactoryQuotation"));

const MobileHome = loadable(() => import("./views/mobile/Home/Home"));
//后台管理系统页面

const Root = window.Root || (window.Root = ReactDOM.createRoot(document.getElementById('root')!));

Root.render(

    (() => {
        const isMobile = getBrowserInfo().device === "Mobile";
        return (
            <ConfigProvider
                locale={zhCN}
                theme={{
                    token: {
                        colorPrimary: '#5503FA',
                    },
                }}
            >


                <Router history={hashHistory} >
                    {/* <PwaModal /> */}

                    {/* 登录弹窗 */}
                    <LoginModal />

                    {/* 文件查看弹窗 */}
                    <FileLookModal />

                    {
                        isMobile ?
                            <Routes>
                                <Route path="/" element={<MobileHome />} />
                            </Routes>
                            :
                            <>
                                <Routes>
                                    {/* 主页 */}
                                    <Route path="/" element={<PCHome />} />
                                    {/* 协作页面 */}
                                    <Route path="/partCollaborate/:id" element={<PartCollaborate />} />
                                    {/* 协作页面demo */}
                                    <Route path="/partCollaborateDemo" element={<PartCollaborateDemo />} />
                                    {/* 模型上传页面 */}
                                    <Route path="/updataModel" element={<UpdataModel />} />
                                    {/* 零件库 */}
                                    <Route path="/partsLibrary" element={<PartsLibrary />} />
                                    {/* 查看零件详情 */}
                                    <Route path="/partsDetails/:id" element={<PartsDetails />} />
                                    {/* 项目管理 */}
                                    <Route path="/projectCollaboration" element={<ProjectCollaboration />} />
                                    {/* 项目详情 */}
                                    <Route path="/projectDatail/:id" element={<ProjectDatail />} />
                                    {/* 项目设置 */}
                                    <Route path="/projectSetting/:id" element={<ProjectSetting />} />
                                    {/* 用户订单 */}
                                    <Route path="/userOrder" element={<UserOrder />} />
                                    {/* 账号设置 */}
                                    <Route path="/accountSettings" element={<AccountSettings />} />
                                    {/* FQRS */}
                                    <Route path="/fqrs" element={<FQRS />} />
                                    {/* 询盘 */}
                                    <Route path="/inquiry" element={<Inquiry />} />
                                    {/* 404 */}
                                    <Route path="/404" element={<NotFind />} />

                                    {/* 个人中心 */}
                                    <Route path="/userCenter" element={<UserCenter />} />
                                    {/* 后台登录 */}
                                    <Route path="/adminLogin" element={<AdminLogin />} />

                                    {/* 后台页面 */}
                                    <Route
                                        path={"/admin/*"}
                                        element={
                                            <AdminLayer>
                                                <Routes>
                                                    {/*  用户管理 */}
                                                    <Route path="/adminUserManage" element={<AdminUserManage />} />
                                                    {/*  厂商管理 */}
                                                    <Route path="/adminFactoryManage" element={<AdminFactoryManage />} />
                                                    {/* 服务类型 */}
                                                    <Route path="/adminServerType" element={<AdminServerType />} />
                                                    {/* 加工类目 */}
                                                    <Route path="/adminProcessCategory" element={<AdminProcessCategory />} />

                                                </Routes>
                                            </AdminLayer>
                                        }
                                    />

                                    {/* 工厂页面 */}
                                    <Route
                                        path={"/factory/*"}
                                        element={
                                            <FactoryLayer>
                                                <Routes>
                                                    {/* 厂商报价请求 */}
                                                    <Route path="/factoryQuotation" element={<FactoryQuotation />} />
                                                    {/* 厂商的订单 */}
                                                    <Route path="/" element={<FactoryOrder />} />
                                                    <Route path="/factoryOrder" element={<FactoryOrder />} />
                                                    {/* 厂商设置 */}
                                                    <Route path="/setting" element={<FactorySetting />} />
                                                    {/* 厂商中心 */}
                                                    <Route path="/center" element={<FactoryCenter />} />
                                                </Routes>
                                            </FactoryLayer>
                                        }
                                    />
                                </Routes>
                            </>
                    }
                </Router>
            </ConfigProvider>
        )
    })()
);

//@ts-ignore
console.log("前端发版时间", process.env.BUILD_TIME);
console.log("程序问题反馈联系方式 %cqq389652405", 'color: red');